﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Web.Configuration;

public partial class Admin_CustomerDisable : System.Web.UI.Page
{
    ShopLaptopConnection connect;
    SqlConnection conn;
    protected void Page_Load(object sender, EventArgs e)
    {
        connect = new ShopLaptopConnection();
        conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["ShopLaptopConnectionString"].ConnectionString);
        if (!IsPostBack)
        {
            if (Session["Admin"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            DisplayCusStatus0();

        }

    }

    protected void DisplayCusStatus0()
    {
        grCustomerDisable.DataSource = "";
        grCustomerDisable.DataBind();
        SqlDataAdapter da = new SqlDataAdapter("Select * From Customer Where CusStatus=0", conn);
        DataTable dt = new DataTable();
        da.Fill(dt);
        if (dt.Rows.Count > 0)
        {
            grCustomerDisable.DataSource = dt;
            grCustomerDisable.DataBind();
        }
    }

    protected void grCustomerDisable_SelectedIndexChanged(object sender, EventArgs e)
    {
        int cusID = Convert.ToInt32(grCustomerDisable.Rows[grCustomerDisable.SelectedIndex].Cells[0].Text);
        //Response.Write(cusID.ToString());
        int check = 0;
        check = connect.SetCusStatus1(cusID);
        if (check > 0)
        {
            DisplayCusStatus0();

        }
    }
}
